#include <iostream>
#include <string>
#include "email_verification.hpp"

int main() {
    std::cout << "🚀 邮箱验证码系统 - 支持SSL/TLS" << std::endl;
    
    // QQ邮箱SSL配置
    std::string smtp_server = "smtp.qq.com";
    int port = 587;  // STARTTLS端口
    std::string email_user = "1581558945@qq.com";  // 您的QQ邮箱
    std::string email_pass = "amdmrhiqfowvihgf";          // QQ邮箱授权码
    std::string sender_name = "验证码系统";
    
    // 创建验证系统实例
    EmailVerificationSystem verification_system(
        smtp_server, port, email_user, email_pass, sender_name
    );
    
    // 测试用户信息
    std::string user_email = "3754117618@qq.com";
    
    std::string user_name;
    std::cout << "👤 请输入用户名 (可选): ";
    std::cin.ignore();
    std::getline(std::cin, user_name);
    
    // 发送验证码
    std::cout << "\n📤 正在发送验证码..." << std::endl;
    if (verification_system.sendVerificationCode(user_email, user_name)) {
        std::cout << "✅ 验证码发送成功！请检查邮箱。" << std::endl;
        
        // 验证验证码
        std::string input_code;
        std::cout << "\n🔢 请输入收到的验证码: ";
        std::cin >> input_code;
        
        std::cout << "\n🔍 正在验证..." << std::endl;
        if (verification_system.verifyCode(user_email, input_code)) {
            std::cout << "🎉 验证成功！用户注册完成。" << std::endl;
        } else {
            std::cout << "❌ 验证失败！" << std::endl;
        }
    } else {
        std::cout << "❌ 验证码发送失败，请检查配置！" << std::endl;
    }
    
    return 0;
}